from typing import List


class Solution:
    def findRotation(self, mat: List[List[int]], target: List[List[int]]) -> bool:
        n = len(mat)

        maybe = True
        for i in range(n):
            for j in range(n):
                if mat[i][j] != target[i][j]:
                    maybe = False
                    break
            if not maybe:
                break
        if maybe:
            return True

        maybe = True
        for i in range(n):
            for j in range(n):
                if mat[i][j] != target[j][n - i - 1]:
                    maybe = False
                    break
            if not maybe:
                break
        if maybe:
            return True

        maybe = True
        for i in range(n):
            for j in range(n):
                if mat[i][j] != target[n - i - 1][n - j - 1]:
                    maybe = False
                    break
            if not maybe:
                break
        if maybe:
            return True

        maybe = True
        for i in range(n):
            for j in range(n):
                if mat[i][j] != target[n - j - 1][i]:
                    maybe = False
                    break
            if not maybe:
                break
        if maybe:
            return True

        return False


if __name__ == "__main__":
    # True
    print(Solution().findRotation(mat=[[0, 1], [1, 0]], target=[[1, 0], [0, 1]]))

    # False
    print(Solution().findRotation(mat=[[0, 1], [1, 1]], target=[[1, 0], [0, 1]]))

    # True
    print(Solution().findRotation(mat=[[0, 0, 0], [0, 1, 0], [1, 1, 1]],
                                  target=[[1, 1, 1], [0, 1, 0], [0, 0, 0]]))

    # 自制用例 : True
    print(Solution().findRotation(mat=[[0, 1],
                                       [1, 1]],
                                  target=[[1, 1],
                                          [1, 0]]))
    # 自制用例 : True
    print(Solution().findRotation(mat=[[0, 1],
                                       [1, 1]],
                                  target=[[1, 1],
                                          [0, 1]]))

    # 自制用例 : True
    print(Solution().findRotation(mat=[[0, 1],
                                       [1, 1]],
                                  target=[[0, 1],
                                          [1, 1]]))

    # 自制用例 : True
    print(Solution().findRotation(mat=[[0, 1],
                                       [1, 1]],
                                  target=[[1, 0],
                                          [1, 1]]))
